<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.controller');
/**
 * Hello World Component Controller
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class SetControllerStore extends JController
{
	function __construct(){
	    parent::__construct();
	    // Register Extra tasks
	    $this->registerTask('add','edit');
	    $this->registerTask('addstore','edit');
	    $this->registerTask('editstore','edit');
	}
    /**
     * 店铺管理
     *
     */
    function mngstore(){
    	$model	= &$this->getModel( 'Store' );
		$view	= &$this->getView( 'store','html');
		$view->setModel( $model, true );
		$view->display();
    }
    /**
     * 添加店铺
     *
     */
    function edit(){
		$model	=& $this->getModel( 'Store' );		
    	$view = $this->getView('storeform','html');
    	$view->setModel( $model, true );
    	$view->display();
    }
    /**
	 * remove record(s)
	 * @return void
	 */
	function remove()
	{
		$model = $this->getModel('Store');
		if(!$model->delete()) {
			$msg = JText::_( 'Error: One or More Stores Could not be Deleted' );
		} else {
			$msg = JText::_( 'Store(s) Deleted' );
		}

		$link = 'index.php?option=com_set&controller=store&view=items&task=mngstore';
		$this->setRedirect($link, $msg);
	}
    function cancel(){
    	$link = 'index.php?option=com_set&controller=store&view=items&task=mngstore';
		$this->setRedirect($link, $msg);
    }
    function save(){    
    	
    	$model = $this->getModel('store');
    	
		if ($model->store()) {
			$msg = JText::_( 'Store Saved!' );
		} else {
			$msg = JText::_( 'Error Saving Store' );
		}

		// Check the table in so it can be edited.... we are done with it anyway
		$link = 'index.php?option=com_set&controller=store&view=items&task=mngstore';
		$this->setRedirect($link, $msg);
    }
}
?>
